export default {
  namespaced: true, //命名空间
  state: {
    //实习方向的data表格的数据,
    SXDirectionData: [],
    //实习方向选中Key
    SXDirectionKey: [`0`],

    //实习小组的data表格的数据,
    SXGroupData: [],
    //实习小组选中Key
    SXGroupKey: [`0`],
    //控制提交申请的遮罩层
    SpinningState: false,
  },
  getters: {
    //选中的实习方向data
    selectDirection(state) {
      return state.SXDirectionData.find(
        (item) => item.key == state.SXDirectionKey[0]
      );
    },
    //选中的实习小组data
    selectGroupData(state) {
      return state.SXGroupData.find((item) => item.key == state.SXGroupKey[0]);
    },
  },
  mutations: {
    setSpinningState(state) {
      state.SpinningState = !state.SpinningState;
    },
    setSXDirectionData(state, data) {
      if (state.SXDirectionKey[0] == 0)
        state.SXDirectionKey = [`${data[0].key}`];

      state.SXDirectionData = data;
    },
    setSXDirectionKey(state, data) {
      state.SXDirectionKey = [`${data}`];
    },
    setSXGroupData(state, data) {
      if (!data.some((item) => item.key == state.SXGroupKey[0]))
        state.SXGroupKey = [`${data[0].key}`];
      state.SXGroupData = data;
    },
    setSXGroupKey(state, data) {
      state.SXGroupKey = [`${data}`];
    },
  },
  actions: {},
  modules: {},
};
